<template>
  <el-dialog title="操作日志详情" :visible.sync="dialogVisible">
    <el-form ref="detailForm" :model="detail" label-width="80px" size="small">
      <el-row>
        <el-col :span="24">
          <el-form-item prop="name" label="操作名称">
            <span class="content">{{dataTransform(detail.actionName)}}</span>
          </el-form-item>
          <el-form-item prop="name" label="方法">
            <span class="content">{{detail.methodName}}</span>
          </el-form-item>
          <el-form-item prop="name" label="方法参数">
            <span class="content">{{detail.methodParams}}</span>
          </el-form-item>
          <el-form-item prop="name" label="模块">
            <span class="content">{{detail.moduleTitle}}</span>
          </el-form-item>
          <el-form-item prop="name" label="Ip">
            <span class="content">{{detail.operIp}}</span>
          </el-form-item>
          <el-form-item prop="name" label="位置" v-if="detail.operLocation">
            <span class="content">{{detail.operLocation}}</span>
          </el-form-item>
          <el-form-item prop="name" label="URL">
            <span class="content">{{detail.operUrl}}</span>
          </el-form-item>
          <el-form-item prop="name" label="操作人">
            <span class="content">{{detail.userName}}</span>
          </el-form-item>
          <el-form-item prop="name" label="时间">
            <span class="content">{{dateFormat(detail.operationDatetime)}}</span>
          </el-form-item>
          <el-form-item prop="name" label="状态">
            <span class="content">{{detail.status > 0?"成功": "失败"}}</span>
          </el-form-item>
          <el-form-item prop="name" label="异常">
            <span class="content">{{detail.errorMsg}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item class="from-bnts">
        <el-button type='primary' @click="dialogVisible=false">确定</el-button>
      </el-form-item>
    </el-form>

  </el-dialog>

</template>
<script>
  import discretionApi from "@/api/system/discretion";
  import moment from 'moment/moment';
  export default {
    data() {
      return {
        loading: false,
        dialogVisible: false,
        detail: {},
      };
    },
    methods: {
      async initPage(detail) {
        this.dialogVisible = true;
        this.detail = detail || {};
      },
      dateFormat(val){
        return moment(val).format('YYYY-MM-DD HH:mm:ss')
      },
      dataTransform(val){
        switch(val){
          case '0':
            return "其他";
            break;
          case '1':
            return '新增';
            break;
          case '2':
            return '修改';
            break;
          case '3':
            return '保存';
            break;
          case '4':
            return '删除';
            break;
          case '5':
            return '授权';
            break;
          case '6':
            return '导出';
            break;
          case '7':
            return '导入';
            break;
          case '8':
            return '强退';
            break;
          case '9':
            return '禁止访问';
            break;
          case '10':
            return '生成代码';
            break;
        }
      },
    }
  };
</script>
<style lang="scss" scoped>
  .el-form-item{
    .content{
      display:block;
      padding:5px;
      max-height:100px;
      overflow: auto;
      background:#e6e6e6;
      border-radius:3px;
    }
  }
</style>


